//
//  AccountInfoModel.m
//  zaipin
//
//  Created by whj on 16/10/9.
//  Copyright © 2016年 master. All rights reserved.
//

#import "AccountInfoModel.h"
#import "AccountManager.h"
@implementation AccountInfoModel


-(BOOL)isLogin{
    if (self.user_token == nil || self.user_token.length == 0) {
        _login = NO;
    }else{
        _login = YES;
    }
    return _login;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"\n{\n  phone = %@,\n  member_id = %@,\n 登录状态 = %@,\n user_token = %@}",self.phone, self.member_id, self.isLogin?@"登录":@"未登录",self.user_token];
}


/**
 *  当从文件中解析出一个对象的时候调用
 *  在这个方法中写清楚：怎么解析文件中的数据
 */
- (id)initWithCoder:(NSCoder *)decoder
{
    if (self = [super init]) {
        self.phone = [decoder decodeObjectForKey:@"phone"];
        self.password = [decoder decodeObjectForKey:@"password"];
        self.member_id = [decoder decodeObjectForKey:@"member_id"];
        self.user_token = [decoder decodeObjectForKey:@"user_token"];
      
    }
    return self;
}

/**
 *  将对象写入文件的时候调用
 *  在这个方法中写清楚：要存储哪些对象的哪些属性，以及怎样存储属性
 */
- (void)encodeWithCoder:(NSCoder *)encoder
{
    [encoder encodeObject:self.member_id forKey:@"member_id"];
    [encoder encodeObject:self.phone forKey:@"phone"];
    [encoder encodeObject:self.password forKey:@"password"];

    if (_login) {
        [encoder encodeObject:self.user_token  forKey:@"user_token"];
    }else{
        [encoder encodeObject:@""  forKey:@"user_token"];
    }
}



@end
